<?php

namespace App\Admin\Grids;

use App\Admin\Actions\HospitalAppointVaccineDeleteAction;
use App\Models\HospitalUploadData;
use Dcat\Admin\Admin;
use Dcat\Admin\Widgets\Form;
use App\Admin\Field\IntervalWeekNum;
use App\Admin\Forms\HospitalAppointVaccineForm;
use App\Models\HospitalAppointInterval;
use App\Models\HospitalAppointIntervalNum;
use App\Hospital\Repositories\HospitalAppointVaccine;
use App\Models\Vaccine;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\GridAction;
use Dcat\Admin\Grid\LazyRenderable;
use Dcat\Admin\Grid\RowAction;
use Illuminate\Support\Facades\DB;

class HospitalUploadDataGrid extends LazyRenderable
{
    public function grid(): Grid
    {
        $data = $this->payload;
        return Grid::make(new HospitalUploadData(), function (Grid $grid) use($data){
            $grid->model()->orderBy('id', 'desc');
            $grid->disableFilter();
            $grid->disableFilterButton();

            $grid->model()->where('hospital_id',$data['hospital_id']);

            $grid->column('status','状态')->using([
                0=>'上传成功等待处理中',
                1=>'文件处理中',
                2=>'文件解析完成，正在同步数据',
                3=>'数据同步完成',
                4=>'比配失败，未查询到对应表头'
            ]);
            $grid->column('type')->using([
                0=>'无',
                1=>'体检',
                2=>'孕期',
                3=>'妇幼',
                4=>'免疫'
            ]);
            $grid->column('created_at');
            $grid->showCreateButton();
            $grid->enableDialogCreate();
            $grid->disableEditButton();
            $grid->disableDeleteButton();

            $grid->setResource('hospital-appoint-vaccine');
            $grid->disableFilter();
            $grid->disableCreateButton();
            $grid->disableActions();

            $grid->setActionClass(Grid\Displayers\Actions::class);
            $grid->showQuickEditButton();
            $grid->disableViewButton();
            $grid->disableRowSelector();
            $grid->model()->setConstraints([
                'hospital_id' => $data['hospital_id'],
            ]);
        });
    }

}
